import axios from "axios";
import React, { useEffect, useState } from "react";
import { useLocation, useParams } from "react-router-dom";
function Deatil() {
  const { id } = useParams();
  console.log(id);
  const [list, setList] = useState([]);

  const getlist = async () => {
    const res = await axios.get(`/api/article/${id}`);
    console.log(res);
    setList(res.data)
  };
  useEffect(() => {
    getlist();
  }, []);
  return (
    <div>
      <div >
        <h2>{list.title}</h2>
        <p>{list.content}</p>
        时间：{list.createdAt}
      </div>
    </div>
  );
}

export default Deatil;
